home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
tobby_on_ice.swf
/
scripts
/
DefineSprite_197_bull
/
frame_1
/
DoAction.as
Wrap
Text File
|
2011-08-19
|
3KB
|
132 lines
function main()
{
var _loc1_ = this;
switch(_loc1_.stat)
{
case "walk":
_loc1_.walk();
break;
case "walk2":
_loc1_.walk2();
break;
case "stay2":
_loc1_.stay2();
}
_loc1_.hitCheck();
}
function reSetLoc()
{
var _loc1_ = this;
_loc1_.stat = _loc1_.initStatList[_root.stageNum - 1];
_loc1_.anmStat = "walk";
_loc1_.anmMC.gotoAndPlay("walk");
_loc1_.walkDirect = -1;
_loc1_._xscale = -100;
_loc1_.worldx = 0;
_loc1_.baseX = _loc1_.initX;
_loc1_._y = _loc1_.initY;
_loc1_.pdx = _loc1_.pdxList[_root.stageNum - 1];
}
function hitCHeck()
{
var _loc2_ = this;
if(_loc2_.hitTest(_root.tobbyMC))
{
var _loc1_ = _root.tobbyMC.hitBull();
if(_loc1_)
{
_loc2_.stat = "win";
_loc2_.anmMC.gotoAndPlay("win");
}
}
}
function walk()
{
var _loc1_ = this;
if(_loc1_.anmStat != "walk")
{
_loc1_.anmStat = "walk";
_loc1_.anmMC.gotoAndPlay("walk");
}
_loc1_.worldx += _loc1_.pdx * _loc1_.walkDirect;
if(_loc1_.worldx > 0)
{
_loc1_.worldx = 0;
_loc1_.walkDirect = -1;
_loc1_._xscale = -100;
}
if(_loc1_.worldx < -950)
{
_loc1_.worldx = -950;
_loc1_.walkDirect = 1;
_loc1_._xscale = 100;
}
}
function walk2()
{
var _loc1_ = this;
var _loc2_ = _loc1_._x - _root.tobbyMC._x;
if(Math.abs(_loc2_) < 10)
{
_loc1_.stat = "stay2";
_loc1_.ptr = _loc1_.alg2WaitTime;
_loc1_.anmStat = "stay";
_loc1_.anmMC.gotoAndStop("stay");
}
else
{
if(_loc1_.anmStat != "walk")
{
_loc1_.anmStat = "walk";
_loc1_.anmMC.gotoAndPlay("walk");
}
if(_loc2_ > 0)
{
_loc1_.walkDirect = -1;
_loc1_._xscale = -100;
}
else
{
_loc1_.walkDirect = 1;
_loc1_._xscale = 100;
}
_loc1_.worldx += _loc1_.pdx * _loc1_.walkDirect;
if(_loc1_.worldx > 0)
{
_loc1_.worldx = 0;
_loc1_.walkDirect = -1;
_loc1_._xscale = -100;
}
if(_loc1_.worldx < -950)
{
_loc1_.worldx = -950;
_loc1_.walkDirect = 1;
_loc1_._xscale = 100;
}
}
}
function stay2()
{
var _loc1_ = this;
_loc1_.ptr = _loc1_.ptr - 1;
if(_loc1_.ptr <= 0)
{
_loc1_.stat = "walk2";
}
}
this.initStatList = ["walk","walk2","walk","walk2","walk2"];
this.stat = this.initStatList[_root.stageNum - 1];
this.alg2WaitTimeList = [20,15,20,30,20];
this.alg2WaitTime = this.alg2WaitTimeList[_root.stageNum - 1];
this.ptr = 0;
this.pdxList = [4,3,5,5,6];
this.pdx = this.pdxList[_root.stageNum - 1];
this.walkDirect = -1;
this._xscale = -100;
this.worldx = 0;
this.initX = this._x;
this.initY = this._y;
this.baseX = this.initX;
this.anmStat = "walk";
this.anmMC.gotoAndPlay("walk");